<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@ include file="/include/taglibs.jsp"%>
<html>
<head>
	<title>编辑字典</title>
	<%@ include file="/include/openstyles.jsp"%>
	<script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/jquery.validate.min.js"></script>
	<script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/validate-methods.js"></script>
	<script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/jquery/jquery-form.js"></script>
	<script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/input.js"></script>
	<script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/lui.jiantingdiv.js"></script>
	<script type="text/javascript" src="${ctx}/assets/uc/js/common.js"></script>
	<style>
		.help-block{
			margin: 0px!important;
		}
	</style>
</head>
<body>
<div class="row">
	<div class="col-xs-12">
		<div class="space-12"></div>
		<form class="form-horizontal" role="form" id="item_form">
			<div class="tabbable">
				<div class="profile-user-info profile-user-info-striped">
					<div class="profile-info-row">
						<div class="profile-info-name" >字典编号：</div>
						<div class="profile-info-value">
							<input type="text" id="id" name="id"
								   class="col-xs-10 col-sm-8 " placeholder="字母数字和下划线组成"  />
						</div>
					</div>
					<div class="profile-info-row">
						<div class="profile-info-name" >字典名称：</div>
						<div class="profile-info-value">
							<input type="text" id="name" name="name"
								   class="col-xs-10 col-sm-8" placeholder="汉字字母数字或下划线组成" />
						</div>
					</div>
					<div class="profile-info-row">
						<div class="profile-info-name" >排序字段：</div>
						<div class="profile-info-value">
							<input type="text" id="order" name="order"
								   class="col-xs-10 col-sm-8" placeholder="数字组成" />
						</div>
					</div>
					<div class="profile-info-row">
						<div class="profile-info-name" > 描述：</div>
						<div class="profile-info-value">
									<textarea class="col-xs-10 col-sm-8" style="resize:none;padding-left:3px !important;"
											  maxlength="200" rows="3" id="description" name="description"></textarea>
						</div>
					</div>
				</div>
			</div>
		</form>
	</div>
</div>


<script type="text/javascript">

	var form = "item_form";
	var $form = $("#"+form);

	jQuery(function($) {

		fillForm();

		$form.validate({
			rules: {
				'name': {
					required: true
				},
				'order': {
					required: true
				},
				'id': {
					required: true
				}
			},

			messages: {
				'name':{
					required: "名称不能为空"
				},
				'order': {
					required: "排序字段不能为空"
				},
				'id': {
					required: "编号不能为空"
				}
			}
		});

	});

	function fillForm(){
		$.ajax({
			type:'GET',
			url:'${ctx}/${frameworkPath}/item/view/${param.id}',
			dataType:'json',
			success:function(data){
				loadData(data.rows,$form);
			},
			error: function(XmlHttpRequest, textStatus, errorThrown){
				bootbox.alert('加载数据错误');
			}
		});
	}

	function formValid(){
		var retObj =new Object();
		var valid = $("#item_form").valid();
		if (valid) {
			$form.ajaxSubmit({
				url : "${ctx}/${frameworkPath}/item/edit/${param.id}",
				type : "post",
				async :false,
				dataType:'json',
				success : function(message) {
					if (message.success) {
						retObj.text ="保存成功！";
						retObj.state = true;
					} else {
						retObj.text = text;
						retObj.state =false;
					}
				}
			});
		} else {
			return;
		}
		return retObj;
	}
</script>
</body>
</html>